package com.cloud.activiti.listener;

import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * 全局监听器
 */
@Component
public class CustomizeActivitiEventListener implements ActivitiEventListener, Serializable {
    @Override
    public void onEvent(ActivitiEvent event) {

        switch (event.getType()) {
            //流程开始
            case PROCESS_STARTED:
                System.out.println("流程开始");
                break;
            //流程结束
            case PROCESS_COMPLETED:
                System.out.println("流程结束");
                break;
            //任务开始
            case TASK_CREATED:
                System.out.println("任务开始");
                break;
            //任务完成
            case TASK_COMPLETED:
                System.out.println("任务完成");
                break;
            //流程结束
            case PROCESS_CANCELLED:
                System.out.println("流程结束");
            default:
        }
    }

    @Override
    public boolean isFailOnException() {
        return false;
    }
}
